From d861c10c24742a04e8452dd7fc09e961a0ec6be4 Mon Sep 17 00:00:00 2001 From: Christian Limpach Date: Thu, 8 Mar 2007 15:51:32 +0000 Subject: [PATCH] [xen] Update the hvm rtc clock state if the domain's time offset is changed. The settimeoffset domctl had no effect on hvm domains since the offset was only read in rtc_init which is done when the domain is created. Signed-off-by: Christian Limpach --- xen/arch/x86/hvm/rtc.c | 15 +++++++++++++-- xen/include/asm-x86/hvm/vpt.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c index 5cda6bbb75..036eba7bfe 100644 --- a/xen/arch/x86/hvm/rtc.c +++ b/xen/arch/x86/hvm/rtc.c @@ -174,6 +174,11 @@ static void rtc_copy_date(RTCState *s) { const struct tm *tm = &s->current_tm; + if (s->time_offset_seconds != s->pt.vcpu->domain->time_offset_seconds) { + s->current_tm = gmtime(get_localtime(s->pt.vcpu->domain)); + s->time_offset_seconds = s->pt.vcpu->domain->time_offset_seconds; + } + s->hw.cmos_data[RTC_SECONDS] = to_bcd(s, tm->tm_sec); s->hw.cmos_data[RTC_MINUTES] = to_bcd(s, tm->tm_min); if ( s->hw.cmos_data[RTC_REG_B] & RTC_24H ) @@ -211,10 +216,16 @@ static int get_days_in_month(int month, int year) } /* update 'tm' to the next second */ -static void rtc_next_second(struct tm *tm) +static void rtc_next_second(RTCState *s) { + struct tm *tm = &s->current_tm; int days_in_month; + if (s->time_offset_seconds != s->pt.vcpu->domain->time_offset_seconds) { + s->current_tm = gmtime(get_localtime(s->pt.vcpu->domain)); + s->time_offset_seconds = s->pt.vcpu->domain->time_offset_seconds; + } + tm->tm_sec++; if ((unsigned)tm->tm_sec >= 60) { tm->tm_sec = 0; @@ -258,7 +269,7 @@ static void rtc_update_second(void *opaque) } else { - rtc_next_second(&s->current_tm); + rtc_next_second(s); if ( !(s->hw.cmos_data[RTC_REG_B] & RTC_SET) ) s->hw.cmos_data[RTC_REG_A] |= RTC_UIP; diff --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h index 02bc3fa05c..bda54adfc3 100644 --- a/xen/include/asm-x86/hvm/vpt.h +++ b/xen/include/asm-x86/hvm/vpt.h @@ -92,6 +92,7 @@ typedef struct RTCState { struct timer second_timer; struct timer second_timer2; struct periodic_time pt; + int32_t time_offset_seconds; } RTCState; #define FREQUENCE_PMTIMER 3579545 /* Timer should run at 3.579545 MHz */ -- 2.30.2